package com.ailink.foodshop.utils;

import com.ailink.foodshop.enums.CodeEnum;

/**
 * @author lh
 * @date 2017/12/24 21:50
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }

}
